import request from '@/utils/request';

// 查询员工档案数据
export function getStaff(query: any) {
	if (typeof query === 'object' && query !== null) {
		return request({
			url: `/hr/staff`,
			method: 'get',
			params: query,
		});
	} else {
		return request({
			url: `/hr/staff/${query}`,
			method: 'get',
		});
	}
}

// 新增员工档案
export function addStaff(data: any) {
	return request({
		url: '/api/hr/staff',
		method: 'post',
		data: data,
	});
}

// 修改员工档案
export function updateStaff(id: any, data: any) {
	return request({
		url: `/hr/staff/${id}`,
		method: 'put',
		data: data,
	});
}

// 删除员工档案
export function delStaff(id: any) {
	const newIds = Array.isArray(id) ? id : [id];
	return request({
		url: '/api/hr/staff',
		method: 'delete',
		params: {
			staff_id: newIds,
		},
	});
}
